var emailFlag = true;
var mobileFlag = true;
var contentFlag = true;

function submitFeedBack(){
	validateMobile();
	validateEmail();
	validateContent();
	
	if(emailFlag == true && mobileFlag == true && contentFlag == true){
       document.feedbackForm.submit();
	}
}

function resetFeedBack(){
	document.feedbackForm.reset();
}

function getfocus(type){
	document.getElementById(type).style.display = ""; // 显示
	
	if("mobileInfo" == type){
		document.getElementById("mobileError").style.display = "none";
	}
	if("emailInfo" == type){
		document.getElementById("emailError").style.display = "none";
	}
}

function loseblur(type){
	document.getElementById(type).style.display = "none"; // 隐藏
	
	if("emailInfo" == type){
		validateEmail();
	}
	if("mobileInfo" == type){
		validateMobile();
	}
}

function validateContent(){
	if($("#content").val() == ""){
		contentFlag = false;
		$("#contentError").show();
	}else{
		contentFlag = true;
		$("#contentError").hide();
	}
}

function validateMobile(){
	var re= /^(1)\d{10}$/;
	
	if($("#mobile").val() != ""){
	  if(re.test($("#mobile").val())){
		mobileFlag = true;
		$("#mobileError").hide();
	  }else{
		$("#mobileError").show();
		mobileFlag = false;
      }
	}else{
		mobileFlag = true;
		$("#mobileError").hide();
	}
}

function validateEmail(){
	var email = document.getElementById("email").value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	if(email == ""){
		document.getElementById("emailError").style.display = "none";
		emailFlag = true;
		return;
	}
	
	if (!filter.test(email)){
	   document.getElementById("emailError").style.display = ""; // 显示
	   emailFlag = false;
	}else{
		 document.getElementById("emailError").style.display = "none";
		 emailFlag = true;
	}
}